<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>应用下载引导</title>
    <script>
        // 检测设备环境
        function detectStore() {
            const isAndroid = /android/i.test(navigator.userAgent);
            const isOppo = /oppo/i.test(navigator.userAgent);
            const isXiaomi = /mi\s|redmi|xiaomi/i.test(navigator.userAgent);

            // const huaweiChal = "appmarket://details?id=<PackageName>"; // 华为
            // const vivoChal = "vivoMarket://details?id=<PackageName>"; // vivo
            // const qqChal = "tmast://appdetails?pname=<PackageName>"; // 应用宝  直接下载
            // const baiduChal = "http://market.android.com/details?id=<PackageName>"; // 百度 搜狗 网页
            // const jinliChal = "http://m.appgionee.com/marketdetail?id=<PackageName>"; // 金立 网页
            // const xiaomiChal = "mimarket://details?id=<PackageName>"; // 小米
            // const lenovoChal = "http://market.lenovomm.com/details?id=<PackageName>"; // 联想
            // const anzhiChal = "anzhimarket://details?id=<PackageName>"; // 安智市场
            // const meizuChal = "mstore://details?package_name=<PackageName>"; // 魅族
            // const samsungChal = `samsungapps://ProductDetail/${packageName}`; // 三星

            const appPackageName = "com.anker.charging"; // 替换为实际包名

            // 非Android设备直接跳转网页版
            if (!isAndroid) {
                console.warn("非Android设备");
                return;
            }

            // 尝试唤起Google Play
            // window.location.href = `market://details?id=${appPackageName}`;
            window.location.href = 'https://play.google.com/store/apps/details?id=com.anker.charging';

            // 设置检测超时（500ms后检查是否跳转成功）
            setTimeout(() => {
                // 检测页面是否仍可见（未跳转成功）
                if (!document.hidden && !document.webkitHidden) {
                    // 判断是否为OPPO设备
                    if (isOppo) {
                        // OPPO应用商店跳转方案
                        const oppoLink = `oppomarket://details?packagename=${appPackageName}`;
                        window.location.href = oppoLink;


                    } else if (isXiaomi) {
                        // 小米设备跳转小米应用商店
                        const miStoreUrl = `https://app.mi.com/details?id=${appPackageName}`;
                        window.location.href = miStoreUrl;
                    } else {
                        // 非OPPO设备跳转网页版
                        window.location.href = `https://play.google.com/store/apps/details?id=${appPackageName}`;
                    }
                }
            }, 800);
        }

        // 页面加载后执行检测
        window.onload = detectStore;
    </script>
</head>

<body>
    <p>正在跳转到应用商店，请稍候...</p>
</body>

</html>